package org.hs.phd.odi.tracking.layers;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;

import org.hs.phd.common.simpleplayer.ImageSequenceFrame;
import org.hs.phd.common.simpleplayer.PlayerViewerLayer;
import org.hs.phd.common.simpleplayer.frameviewer.FrameViewer;

public class FrameNoOverlayLayer implements PlayerViewerLayer {
	
	private FrameViewer viewer;
	private boolean isEnabled;

	public FrameNoOverlayLayer(){
		this.isEnabled = true;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		// do nothing
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// do nothing
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// do nothing
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// do nothing
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// do nothing
	}

	@Override
	public void mouseDragged(MouseEvent e) {
		// do nothing
	}

	@Override
	public void mouseMoved(MouseEvent e) {
		// do nothing
	}

	@Override
	public void setViewer(FrameViewer viewer) {
		this.viewer = viewer;
	}

	@Override
	public void paint(Graphics g) {
		Graphics2D g2 = (Graphics2D) g;
		g2.setColor(Color.CYAN);
		ImageSequenceFrame currentFrame = viewer.getPlayer().getCurrentFrame();
		
		if(currentFrame != null){
			String string = "Frame:" + currentFrame.getFrameNo();
			
			int imageRightSideBoundaryX = viewer.getTransformation().modelToView(currentFrame.getFrameImage().width() , 0).x;
			
			int stringWidth = g.getFontMetrics().stringWidth(string);
			g2.drawString(string, imageRightSideBoundaryX - (stringWidth + 20), 20);
		}
	}

	@Override
	public void setEnabled(boolean isEnabled) {
		this.isEnabled = isEnabled;
	}

	@Override
	public boolean isEnabled() {
		return isEnabled;
	}

}
